import App from "./App";

// #ifndef VUE3
import Vue from "vue";
import uView from "uview-ui";

Vue.use(uView);
Vue.prototype.toast = (title, icon = "none") => {
    uni.showToast({
        title,
        icon,
        duration: 3000,
    });
};

let sModal = (content, title = "提示", confirmText = "确认") => {
    let obj = {
        title,
        content,
        confirmText,
    };
    if (typeof content === "object") {
        obj = content;
    }
    return new Promise((resolve, reject) => {
        uni.showModal({
            ...obj,
            complete: (res) => {
                let {confirm} = res;
                if (confirm) {
                    resolve({
                        code: 1,
                        data: true,
                    });
                } else {
                    reject({
                        code: 0,
                        data: false,
                    });
                }
            },
        });
    });
};

import event from './common/event.js'

const Event = new event();
Vue.prototype.$event = Event;

Vue.prototype.sModal = sModal;
import filter from './filter/index.js'

Vue.prototype.$filter = filter
import "./uni.promisify.adaptor";

Vue.config.productionTip = false;
App.mpType = "app";
const app = new Vue({
    ...App,
});
import zmodal from "./components/zy/zy-modal.vue";

Vue.use(zmodal);
import zResult from "./components/zy/zy-result.vue";

Vue.use(zResult);
import zStatus from "./components/zy/zy-status.vue";

Vue.use(zStatus);
import zQuest from "./components/zy/zy-quest.vue";

Vue.use(zQuest);
import zPass from "./components/zy/zy-pass.vue";

Vue.use(zPass);
import zView from "./components/zy/zy-view.vue";

Vue.use(zView);
import zTips from "./components/zy/zy-tips.vue";

Vue.use(zTips);
app.$mount();

// #endif

// #ifdef VUE3
import {createSSRApp} from "vue";

export function createApp() {
    const app = createSSRApp(App);
    return {
        app,
    };
}

// #endif
